<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php
	if (!isset($_SESSION)) {session_start();}
	require("php/akses.php");
	require("php/managesession.php");
	require("php/render.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="stylesheet" type="text/css" href="css/style.css" />
	<script type="text/javascript" src="javascript/foodholic.js"></script>
	<script type="text/javascript" src="javascript/like.js"></script>
	<title>Home</title>
</head>

<body>
	<h3>
		<?php
			connect();
		?>
	</h3>
	<?php require "header.php"; ?>
		
		<div id="content">
			<h2>MOST LIKED</h2>
		<?php
			$contents = searchContent("", 3, 0, "like");
			if (sizeof($contents) == 0) {
				echo "Konten tidak ditemukan";
			} else {
				echo "<div id='left_nav'>";
				$i = 1;
				foreach ($contents as $content) {
					echo "<div class='LikeContent'>
				<a onmouseover='' style='cursor: pointer;' onclick=\"return likeThis('like$i');\" id='staty'>
					<img src='images/like.png' alt='post' name='gambarLike' />
				</a>
				<a onmouseover='' style='cursor: pointer;' onclick=\"return dislikeThis('like$i');\">
					<img src='images/dislike.png' alt='post' />
				</a>
				<div class='likeCount'><a id='like$i'>${content['likes']}</a></div >
				<div><a id='statlike$i'></a></div>
			</div>";
					$i++;
				}
				echo "</div>";
				
				echo "<div id='contents'>";
				foreach ($contents as $content) {
					echo render($content);
				}
				echo "</div>
					<div class='clear'></div>";
			}
			
			echo '</div><div id="content">';
			
			echo "<h2>MOST COMMENTED</h2>";
			$contents = searchContent("", 3, 0, "comment");
			if (sizeof($contents) == 0) {
				echo "Konten tidak ditemukan";
			} else {
				echo "<div id='left_nav'>";
				foreach ($contents as $content) {
					echo "<div class='LikeContent'>
				<a onmouseover='' style='cursor: pointer;' onclick=\"return likeThis('like$i');\" id='staty'>
					<img src='images/like.png' alt='post' name='gambarLike' />
				</a>
				<a onmouseover='' style='cursor: pointer;' onclick=\"return dislikeThis('like$i');\">
					<img src='images/dislike.png' alt='post' />
				</a>
				<div class='likeCount'><a id='like$i'>${content['likes']}</a></div >
				<div><a id='statlike$i'></a></div>
			</div>";
					$i++;
				}
				echo "</div>";
				
				echo "<div id='contents'>";
				foreach ($contents as $content) {
					echo render($content);
				}
				echo "</div>
					<div class='clear'></div>";
			}
		?>
		</div>
		
		<?php require "footer.php"; ?>
	</div>
</body>
</html>